package com.illtamer.infinite.morii.pojo;

import org.springframework.lang.Nullable;

import java.util.Arrays;

public enum VerifyEnum {

    ASC("asc", 0),

    MD5("md5", 1),

    SHA1("sha1", 2);

    final String name;

    /**
     * {@link MoriiVerify#getVerifyMap()}
     * */
    final int index;

    VerifyEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public String getName() {
        return name;
    }

    public int getIndex() {
        return index;
    }

    @Nullable
    public static VerifyEnum getVerifyEnum(String name) {
        return Arrays.stream(values())
                .filter(verifyEnum -> verifyEnum.name.equals(name))
                .findFirst()
                .orElse(null);
    }

}
